<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>

		<a> 我的超链接</a>
		<input id="btn_set" type="button" value="设置属性">
		<input id="btn_rem" type="button" value="删除属性">
		<script>
			// 设置属性
			var btn_set = document.getElementById("btn_set");
			btn_set.onclick = function() {
				var a = document.getElementsByTagName('a')[0];
				a.setAttribute('href', "https://www.baidu.com");
			}

			// 删除属性
			var btn_rem = document.getElementById("btn_rem");
			btn_rem.onclick = function() {
				var a = document.getElementsByTagName("a")[0];
				a.removeAttribute('href');
			}
		</script>

	</body>
</html>
